﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Sengoku
{
    class Board
    {
        private int columns;
        private int rows;
        private Piece[,] board;

        public Board(int c, int r)
        {
            columns = c;
            rows = r;
            board = new Piece[r,c];
        }

        public int getColumns()
        {
            return columns;
        }

        public int getRows()
        {
            return rows;
        }

        public Piece[,] getBoard()
        {
            return board;
        }

        public Piece getPieceAt(int c, int r)
        {
            return board[r, c];
        }

        public void addPieceAt(Piece p, int c, int r)
        {
            board[r, c] = p;
            board[r, c].setPosition(r, c);
        }

        public void removePieceAt(int c, int r)
        {
//            board[r, c].setPosition(-1, -1);
            board[r, c] = null;
        }

        public int numberOfUppercase()
        {
            int num = 0;
            for (int i = 0; i < getColumns(); i++)
                for (int j = 0; j < getRows(); j++)
                    if (getPieceAt(i, j) != null && (getPieceAt(i, j)).getCase() == 1)
                        num++;
            return num;
        }

        public int numberOfLowercase()
        {
            int num = 0;
            for (int i = 0; i < getColumns(); i++)
                for (int j = 0; j < getRows(); j++)
                    if (getPieceAt(i, j) != null && (getPieceAt(i, j)).getCase() == 0)
                        num++;
            return num;
        }
    }
}
